package com.linghui.videoplus.ipai.api;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;

import com.linghui.videoplus.ipai.api.http.HttpClientAPI;

public class VideoPlusServerAPI {

	/**
	 * 用户登录
	 * 
	 * @return
	 * @throws WSError 
	 */
	public String login(String name,String password,String loginUrl) throws WSError {
		String encoderName=null;
		String response=null;
		try {
			encoderName = URLEncoder.encode(name,"UTF-8");
			String[][] rp = { {"username", encoderName}, {"password", password}};
			response = HttpClientAPI.doGet2Api(loginUrl, rp);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return response.trim();
	}

	/**
	 * 注册用户
	 * @return
	 * @throws WSError 
	 */
	public String register(Map<String,String> paraMap) throws WSError {
		String userName= paraMap.get("username");
		String email= paraMap.get("email");
		String password= paraMap.get("password");
		String rePassword= paraMap.get("rePassword");
		String regeditUrl= paraMap.get("regeditUrl");
		String[][] rp = {{ "username",userName},{ "email", email }, { "password", password },{"password2",rePassword}};
		String response = HttpClientAPI.doGet2Api(regeditUrl, rp);
		return response.trim();
	}
	
	
	

}
